﻿Public Class CLDS_Multirow_Container
    Private _CA As CLDS_ACAD
    Private _A1 As String = ""
    Private _A2 As String = ""
    Public Property CA() As CLDS_ACAD
        Get
            Return _CA
        End Get
        Set(ByVal value As CLDS_ACAD)
            _CA = value
        End Set
    End Property
    Public Property A1() As String
        Get
            Return _A1
        End Get
        Set(ByVal value As String)
            _A1 = value
        End Set
    End Property
    Public Property A2() As String
        Get
            Return _A2
        End Get
        Set(ByVal value As String)
            _A2 = value
        End Set
    End Property
    Private Sub lvMultiCable_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lvMultiCable.SelectedIndexChanged
        Dim lv As ListView = DirectCast(sender, ListView)
        If lv.SelectedItems.Count = 1 Then
            Dim lvi As ListViewItem = lv.SelectedItems.Item(0)
            CA.CLDS_RouteCableDetail(CA.pRouteDialog, lvi.Text, lvi.SubItems(1).Text)
        End If
    End Sub

    Private Sub lvMultiSegment_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lvMultiSegment.SelectedIndexChanged
        Dim lv As ListView = DirectCast(sender, ListView)
        If lv.SelectedItems.Count = 1 Then
            Dim lvi As ListViewItem = lv.SelectedItems.Item(0)
            CA.CLDS_SegmentDetail(CA.pSegDialog, lvi.Text, "", "", lvi.SubItems(2).Text, lvi.SubItems(1).Text)
            CA.CLDS_SelectSegment(lvi.SubItems(3).Text, lvi.SubItems(4).Text, True)
        End If
    End Sub
    Private Sub btSelectAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mrToolStripButton3.Click
        Dim lv As ListView
        If Me.tpMultiRow.SelectedTab.Name = Me.tpMCables.Name Then
            lv = Me.lvMultiCable
        Else
            lv = Me.lvMultiSegment
        End If

        For Each lvi As ListViewItem In lv.Items
            lvi.Checked = True
        Next
    End Sub
    Private Sub btSelectNone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mrToolStripButton4.Click
        Dim lv As ListView
        If Me.tpMultiRow.SelectedTab.Name = Me.tpMCables.Name Then
            lv = Me.lvMultiCable
        Else
            lv = Me.lvMultiSegment
        End If

        For Each lvi As ListViewItem In lv.Items
            lvi.Checked = False
        Next
    End Sub
    Private Sub mrToolStripButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mrToolStripButton1.Click
        If _A1 = "Autoroute selected cables" Then
            CA.CLDS_SubmitMultiAR(Me)
        ElseIf _A1 = "Accept selected cable autoroutes" Then
            CA.CLDS_AcceptMultiAR(Me, "UPDATE")
        End If
    End Sub
    Private Sub mrToolStripButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mrToolStripButton2.Click
        If _A2 = "Reject selected cable autoroutes" Then
            CA.CLDS_AcceptMultiAR(Me, "DELETE")
        ElseIf _A2 = "Delete selected cable routes" Then
            CA.CLDS_DeleteMultiCR(Me)
        End If
    End Sub
End Class
